This invention relates generally to methods and systems for processing input/output (I/O) requests in a computer operating system. More particularly, the present invention relates to recoverable methods and systems for processing I/O requests that specify virtual memory addresses to I/O devices.
One goal of a computer operating system is to provide safe and efficient access to I/O devices, such as network communication adapters, permanent storage devices, audio devices, and video devices. The I/O performance of an operating system is affected by the need to translate virtual memory addresses utilized by application programs to physical memory addresses used by hardware devices. For example, in order to access I/O devices, application programs issue I/O requests to the operating system specifying the virtual memory address of data to be written to an I/O device or the virtual memory address where data received from an I/O device is to be stored. A memory manager unit (MMU), which is a hardware component of the host computer, translates virtual memory addresses to physical memory addresses. However, I/O devices are incapable of utilizing the host computer""s MMU to translate virtual memory addresses in I/O requests to physical memory addresses. As a result, conventional I/O devices are presented by the operating system with the physical memory addresses of data processed in I/O operations. In addition, in order to prevent the data to be processed in an I/O operation from being moved to a disk, the operating system locks the virtual memory pages containing the data in main memory for the duration of the I/O operation. The operating system unlocks the virtual pages from main memory when the I/O operation completes. Translating virtual memory addresses to physical memory addresses, locking virtual pages in main memory, and unlocking pages in response to each I/O operation is processor-intensive and increases latency in I/O operations.
In order to increase the efficiency of I/O operations, some I/O devices perform virtual to physical address translations by storing tables mapping virtual memory addresses to physical memory addresses in memory local to the I/O devices. However, these I/O devices are unable to recover if local address translation fails. As a result, the I/O devices require registration and locking of memory regions used in I/O operations prior to performing an I/O operation. Memory registration is initiated by application-level code. The result of memory registration is a memory handle that the application communicates to the I/O device when requesting an I/O operation. The I/O device uses the handle to verify and translate the virtual memory address to a physical memory address. When an application completes use of a memory region, the application deregisters the memory region with the I/O device. Although using memory handles allows applications to specify virtual memory addresses rather than physical memory addresses to I/O devices, registering and deregistering memory regions adds complexity to application programs.
Another problem with conventional I/O devices that require locking of I/O buffers in main memory is that locking may result in inefficient usage of main memory. For example, locking prevents main memory from being used by other applications, even when the locking application is not using the pages stored in main memory. In addition, most operating systems limit the amount of main memory that can be locked by an application to a small percentage, e.g., about sixteen percent, of main memory. The limit on the amount of main memory that can be locked may adversely affect the I/O performance of applications that require locking.
In light of these difficulties, there exists a need for recoverable methods and systems for processing I/O requests that allows applications to specify virtual memory addresses to I/O devices and that reduce the need for preregistration of memory regions or locking of memory regions in main memory.
The present invention alleviates at least some of these difficulties by providing a recoverable I/O request processor for an I/O device capable of automatically translating virtual memory addresses to physical memory addresses, and, if a translation fails, obtaining virtual memory mapping information from the operating system. For example, when an I/O operation, such as a xe2x80x9cWinsockxe2x80x9d send( ) operation, is executed by an application, the virtual memory address of the buffer to be sent using the I/O operation may be communicated directly to the recoverable I/O request processor of the I/O device. The recoverable I/O request processor may attempt to translate the virtual memory address to a physical memory address. If the translation is unsuccessful, the recoverable I/O request processor may request the virtual memory mapping information from the operating system. The operating system may communicate the mapping information to the I/O device. The recoverable I/O request processor may perform the translation and continue processing the I/O operation. Thus, I/O devices according to the present invention may be capable of recovering from address translation failures.
According to another aspect, the present invention includes methods and systems for maintaining coherence between virtual memory mapping information maintained by the recoverable I/O request processor of an I/O device and virtual memory mapping information maintained by the operating system. For example, when a virtual memory page is paged out to a disk, the virtual memory manager or equivalent operating system component preferably notifies the recoverable I/O request processor of an I/O device of the page out before performing the page out. The notification can be performed using a callback function previously registered by an I/O device driver with the virtual memory manager. The callback function may be associated with a particular process or address space. If the virtual memory manager executes a page out that affects an address space having an associated callback function, the callback function may specify that the virtual memory manager inform the I/O device driver of the page out operation. The I/O device driver may inform the recoverable I/O request processor so that the recoverable I/O request processor can update its page tables. In this manner, the virtual address mappings maintained by the recoverable I/O request processor of the I/O device and those maintained by the virtual memory manager may be consistent. Additional operating system interactions that may be used to maintain virtual address mapping coherence include notifying the recoverable I/O request processor of changes in protection attributes associated with virtual memory and allowing the recoverable I/O request processor to request a page in operation to move paged-out virtual memory contents back to main memory.
According to another aspect, the present invention may include a recoverable input/output (I/O) request processor including computer instructions embodied in a computer-readable medium and executable by an I/O device for performing steps. The steps may include receiving requests for performing an I/O operation for writing data to or reading data from a virtual memory address. The recoverable I/O request processor may search for a physical memory address corresponding to the virtual memory address in address translation tables local to the I/O device. If the recoverable I/O request processor fails to locate the physical memory address, the recoverable I/O request processor may request virtual to physical memory mapping information from the host operating system. The recoverable I/O request processor may receive virtual to physical memory mapping operation from the operating system, and, in response, translate the virtual memory address to a physical memory address. After translating the virtual memory address, the recoverable I/O request processor may perform the requested I/O operation.
According to another aspect, the present invention may include a method for maintaining coherence between virtual memory mapping information of a virtual memory manager and virtual memory mapping information of an I/O device. The method may include steps performed by an I/O device driver and a virtual memory manager. The steps performed by the I/O device driver may include registering a callback routine associated with a virtual memory address with a virtual memory manager. The virtual memory manager may receive requests to alter or move the contents of a virtual memory address. In response to the requests, the virtual memory manager may execute the callback routine to notify an I/O device driver of the request.
According to another aspect, the present invention may include a descriptor for communicating an I/O request to an I/O device. The descriptor may include a control field for storing a code indicative of an I/O operation. The descriptor may also include a buffer virtual address field for storing a virtual memory address of a buffer to be utilized in an I/O operation. Further, the descriptor may include a translation error control flag field for storing a translation error control flag for instructing a recoverable I/O request processor of an I/O device to attempt to recover from a virtual address translation failure.
According to another aspect, the present invention may include a method for processing an I/O request. The method may include receiving, at an I/O device, a virtual memory address to be translated to a physical memory address. Next, the I/O device may attempt to translate the virtual memory address to a physical memory address using translation tables local to the I/O device. In response to failing to translate the virtual memory address, the I/O device may generate an interrupt to a host processor and halt processing of the I/O operation. The I/O device may then receive virtual address mapping information from an I/O device driver in response to the interrupt. After receiving the mapping information, the I/O device may restart processing of the I/O operation in response to a request from an application program.
According to a further aspect, the present invention may include a translation error recovery routine for registering memory and restarting processing of an I/O operation when an I/O device fails to translate a virtual memory address to a physical memory address. The translation error recovery routine may include steps or instructions executable by a computer. The steps may include receiving notification that an I/O device is incapable of translating a virtual memory address of data used in an I/O request to a physical memory address. In response to the notification, the translation error recovery routine may request registration of the virtual memory address from a device driver for the I/O device. If the registration is successful, the translation error recovery routine may communicate the virtual memory address to the I/O device for translation.
According to another aspect, the invention may include a system for processing input/output requests for sending and receiving data over a network. The system may include an I/O request queue for receiving descriptors specifying I/O requests from application programs. The system may also include a recoverable I/O request processor for processing the descriptors, including translating the virtual memory addresses of the descriptors to physical memory addresses, suspending processing of the descriptors in the I/O request queue when an address translation failure occurs, and resuming processing of the descriptors when the address translation failure is corrected.
According to yet another aspect, the invention may include a network interface adapter card. The network interface adapter card may include a processing unit and a memory unit coupled to the processing unit. The memory unit may include computer-executable instructions for performing steps. The steps may include translating virtual memory addresses to physical memory addresses. The steps may also include transmitting data from a virtual memory address to a remote machine. When an address translation failure occurs, the steps may include requesting virtual memory mapping information from an operating system.
Additional features and advantages of the invention will be made apparent from the following detailed description of illustrative embodiments which proceeds with reference to the accompanying figures.